﻿using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.ObjectModel;
using Tenmah.BusinessLogic.BusinessEntities;
using Tenmah.BusinessLogic;

namespace Tenmah.Web.Administrator
{
    public partial class Manage_users : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {            
            
            UserCollection ucol = new UserCollection();
            RoleCollection rcol = new RoleCollection();
            rcol.Add(new Role(1, "adminstrator"));
            rcol.Add(new Role(2, "teacher"));
            ucol.Add(new User(1, "David", rcol));
            ucol.Add(new User(2, "Jon", rcol));
            ucol.Add(new User(3, "Max", rcol));
            UsersRepeater.DataSource = ucol;
            DataBind();
        }
        protected void InverseSelectionCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in UsersRepeater.Items)
            {
                CheckBox SelectUserCheckBox = (CheckBox)(item.FindControl("SelectUserCheckBox"));
                SelectUserCheckBox.Checked = SelectUserCheckBox.Checked ? false : true;
            }
        }
        protected void SortByLogOnLinkButton_Click(object sender, EventArgs e)
        {

        }
        protected void SortByLastNameLinkButton_Click(object sender, EventArgs e)
        {

        }
        protected void SortByFirstNameLinkButton_Click(object sender, EventArgs e)
        {

        }
        protected void SortByMiddleNameLinkButton_Click(object sender, EventArgs e)
        {

        }
        protected void SortByFacultyLinkButton_Click(object sender, EventArgs e)
        {

        }
        protected void SortByCafhedraLinkButton_Click(object sender, EventArgs e)
        {

        }
        protected void SortByCourseLinkButton_Click(object sender, EventArgs e)
        {

        }
        protected void SortByGroupLinkButton_Click(object sender, EventArgs e)
        {

        }
        protected void SortByRoleLinkButton_Click(object sender, EventArgs e)
        {

        }
        protected void UsersRepeater_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            
        }
        protected void DeleteUserButton_Click(object sender, EventArgs e)
        {
            Collection<int> SelectedUsers = GetSelectedUsersId();
            if (SelectedUsers.Count > 0)
            {

            }
        }
        public Collection<int> GetSelectedUsersId()
        {
            Collection<int> UsersID = new Collection<int>();
            foreach (RepeaterItem item in UsersRepeater.Items)
            {
                HiddenField UserIdHiddenField = (HiddenField)(item.FindControl("UserIdHiddenField"));
                UsersID.Add(Convert.ToInt32(UserIdHiddenField.Value));
            }
            return UsersID;
        }
    }
}
